package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.Banner;
import com.ysd.util.DBManager;

//实现类
public class BannerDaoImpl { // 实体类名DaoImpl
	
	public List<Banner> getBannerList(){
		List<Banner> bannerList = new ArrayList<Banner>();
		
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from banner");
			while(rs.next()) {
				int bId = rs.getInt("bannerId");
				String bName = rs.getString("bannerImg");
				Banner banner = new Banner(bId, bName); //轮播对象
				bannerList.add(banner);
			}
			return bannerList;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		} finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
